package com.onix.scalecamerapreview.translate.OCR;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;

public class MsWordView extends GraphicOverlay.Graphic {

    private final MsOcrBean.RegionsBean.LinesBean.WordsBean wordsBean;
    private Paint rectPaint;
    private final Paint textPaint;

    public MsWordView(GraphicOverlay overlay, MsOcrBean.RegionsBean.LinesBean.WordsBean wordsBean) {
        super(overlay);
        this.wordsBean = wordsBean;
        //区域
        rectPaint = new Paint();
        rectPaint.setColor(Color.RED);
        rectPaint.setStyle(Paint.Style.STROKE);
        rectPaint.setStrokeWidth(2);


        textPaint = new Paint();
        textPaint.setColor(Color.BLUE);
        textPaint.setTextSize(13);
    }


    @Override
    public void draw(Canvas canvas) {
        String boundingBox = wordsBean.getBoundingBox();
        String text = wordsBean.getText();
        String[] split = boundingBox.split(",");

        RectF rect = new RectF(Float.valueOf(split[0]),Float.valueOf(split[1]),Float.valueOf(split[0])+Float.valueOf(split[2]),Float.valueOf(split[1])+Float.valueOf(split[3]));
        canvas.drawRect(rect, rectPaint);
    }
}
